home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / bin / pssnap / common / polyint.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-17  |  4.0 KB  |  92 lines

  1. #ifndef POLYINT_H
  2. #define POLYINT_H
  3.  
  4. /*
  5.  * PolyZInt
  6.  * Finds intersection of z-axis and arbitrary flat polygon.
  7.  *
  8.  * Input:
  9.  * n_verts          # of vertices in polygon (the length of the verts array)
  10.  * verts            vertices of polygon
  11.  * tol              Tolerance.  Any point whose distance from the z-axis 
  12.  *                  is less than tol will be considered hit.
  13.  *
  14.  * Output:
  15.  * All output values are vvecs (See ooglutil.h).  They must already be 
  16.  * initialized when passed to PolyZInt.  Any new intersection points found
  17.  * by PolyZInt will be appended onto the vvec.  The count field of all the 
  18.  * vvecs must be up to date.  When PolyZInt returns, this field will reflect
  19.  * any new elements that have been added to the vvec (ie, the new count 
  20.  * field will be equal to the old count field plus the number of intersection
  21.  * points found by PolyZInt).  Note that all the vvecs will be the same 
  22.  * length.  PolyZInt will return the number of intersection points found.
  23.  * ip               Intersection points (Point3).  These are the points where
  24.  *                  the Z-axis intersects the plane containing the polygon.
  25.  *                  Note that if tol > 0.0, these points may not actually
  26.  *                  be inside the polygon.
  27.  * vertices         Vertex intersections (ints - indices into verts).  If no
  28.  *                  vertex intersection was found, the corresponding element
  29.  *                  in this vvec will be set to -1.
  30.  * edges            Edge intersections (ints - indices of first point in
  31.  *                  verts list).  If no edge intersection was found, the 
  32.  *                  corresponding element in this vvec will be set to -1.
  33.  * ep               Edge intersection locations, if any were found (Point3).
  34.  *                  An element of this array will contain valid data iff
  35.  *                  the corresponding element of the edges vvec is not equal
  36.  *                  to -1.  The elements of this are guarenteed to be points
  37.  *                  on the edge, but, because of the tolerance, may not be
  38.  *                  equal to the corresponding elements of the ip array.
  39.  * For every intersection point found, ip will be filled in.  vertices will
  40.  * be filled in only if a vertices was within tol of the intersection point.
  41.  * If a vertices was within tol of the intersection point, the edges to which
  42.  * the point belongs will not be considered to have been hit.
  43.  */
  44. int PolyZInt(int n_verts, Point3 *verts, float tol, 
  45.          vvec *ip, vvec *vertices, vvec *edges, vvec *ep);
  46.  
  47. /* 
  48.  * PolyLineInt
  49.  * Finds intersection of arbitrary line and arbitrary flat polygon.
  50.  * pt1              One point on the line
  51.  * pt2              A different point on the line
  52.  * Other arguements as above
  53.  */
  54. int PolyLineInt(Point3 *pt1, Point3 *pt2, int n_verts, Point3 *vert, 
  55.         float tol, vvec *ip, vvec *vertices, vvec *edges, vvec *ep);
  56.  
  57. /* 
  58.  * PolyRayInt
  59.  * Finds intersection of an arbitrary ray and an arbitrary flat polygon.
  60.  * The endpoint is included.
  61.  * pt1              Endpoint of the ray
  62.  * pt2              A different point on the ray
  63.  * Other arguements as above
  64.  */
  65. int PolyRayInt(Point3 *pt1, Point3 *pt2, int n_verts, Point3 *verts, 
  66.            float tol, vvec *ip, vvec *vertices, vvec *edges, vvec *ep);
  67.  
  68. /*
  69.  * PolySegmentInt
  70.  * Finds the intersection of an arbitrary segment and an arbitrary flat
  71.  * polygon.  The endpoints are included.
  72.  * pt1              One endpoint of the segment
  73.  * pt2              The other endpoint of the segment
  74.  * Other arguements as above
  75.  */
  76. int PolySegmentInt(Point3 *pt1, Point3 *pt2, int n_verts, Point3 *verts, 
  77.            float tol, vvec *ip, vvec *vertices, vvec *edges, vvec *ep);
  78.  
  79.  
  80. /*
  81.  * PolyInt_Align
  82.  * Creates a coordinate system such that the first specified point becomes
  83.  * the origin and the second becomes (0, 0, -1)
  84.  * pt1              Point which will map to the origin
  85.  * pt2              Point which will map to (0, 0, -1)
  86.  * T                Matrex in which the transformation will be placed
  87.  */
  88. void PolyInt_Align(Point3 *pt1, Point3 *pt2, Transform T);
  89.  
  90. #endif /* POLYINT_H */
  91.  
  92.